package com.flux.tms.tm${bean.numMain}srv.common.dao;

import java.util.ArrayList;
import java.util.HashMap;
import java.util.LinkedHashMap;
import java.util.List;
import java.util.Map;

import org.mockito.Mock;
import org.mockito.MockitoAnnotations;
import org.testng.annotations.BeforeClass;

import com.flux.wmsv5.comdao.BaseDao;
import com.flux.wmsv5.comobjs.LoginInfoObj;
import com.flux.wmsv5.comservice.DbHelperMysqlImpl;
import com.flux.wmsv5.comservice.SqlParserService;
import com.flux.wmsv5.comservice.api.DbHelper;
import com.flux.wmsv5.utils.RequestIdUtil;

public abstract class CommonDao {
	protected LoginInfoObj loginInfoObj = new LoginInfoObj();
	protected Map<String,String> bizDataMap = new HashMap<String, String>();
	protected Map<String, Object> tmpMap = new HashMap<String, Object>();
	protected List<Map<String, Object>> tmpMapList = new ArrayList<Map<String,Object>>();
	protected LinkedHashMap<String, String> whereDataMap_edit = new LinkedHashMap<String, String>();
	protected DbHelper dbhelper = new DbHelperMysqlImpl();
	protected List<Object[]> objArgs = new ArrayList<Object[]>();
	protected Exception exception = new Exception("A");
	@Mock
	protected SqlParserService sqlParserService;

	protected BaseDao baseDao;
     
	 @BeforeClass
	 public void beforeClass() {
		 CommonDao commondao = returnSubClass();
		 MockitoAnnotations.initMocks(commondao);
	 }	
	 
	 /**
	  * 返回自己对象
	  * 
	  * <p>Author: ${bean.author}
	  * <p>Create Time: ${bean.dayTime}
	  * 
	  * @return
	  */
	 protected abstract CommonDao returnSubClass();
	 
	 /**
	  * 初始化登录对象
	  * 
	  * <p>Author: ${bean.author}
	  * <p>Create Time: ${bean.dayTime}
	  *
	  */
	 protected void initLogin(){
		 loginInfoObj.setUserId("FANGXH");
		 loginInfoObj.setUserName("FANGXHDEBUGSQL");
		 loginInfoObj.setRemoteClientAddr("0.0.0.0");
		 loginInfoObj.setRequestId("ForTest");
		 loginInfoObj.setBizWarehouseId("TEST100");
		 loginInfoObj.setBizOrgId("FLUX");
		 loginInfoObj.setRequestId(RequestIdUtil.createId("A2002"));
		 loginInfoObj.setFunctionId("A2002");
		 initSubLogin();
	 }
	 
	 /**
	  * 子类初始化登录对象
	  * 
	  * <p>Author: ${bean.author}
	  * <p>Create Time: ${bean.dayTime}
	  *
	  */
	 protected abstract void initSubLogin();
	 
	 /**
	  * 初始化业务数据信息
	  * 
	  * <p>Author: ${bean.author}
	  * <p>Create Time: ${bean.dayTime}
	  *
	  */
	 protected void initBizDataMap(){
		 bizDataMap.put("organizationId", "FLUX");
		 bizDataMap.put("warehouseId", "TEST100");
		 initSubBizDataMap();
	 }
	 
	 /**
	  * 子类初始化业务数据信息
	  * 
	  * <p>Author: ${bean.author}
	  * <p>Create Time: ${bean.dayTime}
	  *
	  */
	 protected abstract void initSubBizDataMap();
}
